﻿using System.Collections.Specialized;
using System.IO;
using System.Windows;

namespace Super.Admin.Utils
{
    public static class FileHelper
    {
        /// <summary>
        /// 复制文件
        /// </summary>
        /// <param name="filePaths"></param>
        public static void CopyFiles(params string[] filePaths)
        {
            StringCollection paths = new StringCollection();
            paths.AddRange(filePaths);
            Clipboard.SetFileDropList(paths);
        }
        /// <summary>
        /// 剪切文件
        /// </summary>
        /// <param name="filePaths"></param>
        public static void CutFiles(params string[] filePaths)
        {
            StringCollection paths = new StringCollection();
            paths.AddRange(filePaths);
            DataObject data = new DataObject();
            data.SetFileDropList(paths);
            using (MemoryStream stream = new MemoryStream(new byte[] { 2, 0, 0, 0 }))
            {
                data.SetData("Preferred DropEffect", stream);
                Clipboard.SetDataObject(data);
            }
        }
        /// <summary>
        /// 从剪贴板获取文件列表
        /// </summary>
        /// <returns></returns>
        public static List<string> GetFiles() => Clipboard.ContainsFileDropList() ? Clipboard.GetFileDropList().Cast<string>().ToList() : new List<string>();
    }
}
